import pandas as pd
import SS_set as g

def get_k_data(ss, start, end, ktype='D'):#获取对应类型的K线数据
    kk = ''
    if ktype == 'D':
        kk = kk + '\\day\\'
    if ktype == 'W':
        kk = kk + '\\week\\'
    if ktype == 'M':
        kk = kk + '\\month\\'
    if ktype == '5':
        kk = kk + '\\minute\\'

    ss1 = kk + ss + '.csv'
    base = pd.read_csv(g.datapath + ss1, encoding='gbk')
    base.drop(base.columns[0:1], axis=1, inplace=True)
    base = base[base.date >= start]
    base = base[base.date <= end]
    base = base.reset_index(level=None, drop=True, col_level=0, col_fill='')
    base.code = ['0' * (6 - len(x)) + x for x in base.code.astype(str)]
    return base

